﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:Resources="clr-namespace:Profit.Resources"
                    xmlns:Base="clr-namespace:Core.Base;assembly=Profit.Core" 
                    xmlns:local="clr-namespace:Profit.Controls"
                    xmlns:Enums="clr-namespace:Core.Contracts.Enums;assembly=Profit.Core.Contracts"
                    xmlns:Core="clr-namespace:Core;assembly=Profit.Core" 
                    xmlns:Properties="clr-namespace:Profit.Properties">

    <!-- Application user settings  -->
    <ObjectDataProvider x:Key="AppSettings" ObjectType="{x:Type Properties:Settings}"/>
    
    <Style x:Key="{x:Type GridSplitter}" TargetType="{x:Type GridSplitter}">
        <Setter Property="Background" Value="{StaticResource WhiteBrushKey}"/>
    </Style>
    
    <Style x:Key="slotImageStyle" TargetType="{x:Type Image}">
        <Setter Property="Width" Value="15"/>
        <Setter Property="Height" Value="15"/>
        <Setter Property="Effect" Value="{StaticResource DropShadowEffect}" />
    </Style>

    <Style x:Key="{x:Type Menu}" TargetType="{x:Type Menu}">
        <Setter Property="Background" Value="{StaticResource WhiteBrushKey}"/>
    </Style>

    <Style x:Key="{x:Type MenuItem}" TargetType="{x:Type MenuItem}">
        <Setter Property="Background" Value="{StaticResource WhiteBrushKey}"/>
    </Style>

    <Style x:Key="{x:Type ToolTip}" TargetType="{x:Type ToolTip}">
        <Setter Property="MaxWidth" Value="300"/>
        <Setter Property="UseLayoutRounding" Value="True"/>
        <Setter Property="Padding" Value="5,0,5,2"/>
        <Setter Property="Background" Value="{StaticResource LightBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToolTip}">
                    <Border Background="{TemplateBinding Background}" CornerRadius="3" BorderThickness="1" BorderBrush="{StaticResource DarkGrayBlueBrushKey}" >
                        <TextBlock Margin="{TemplateBinding Padding}" Text="{TemplateBinding Content}" TextAlignment="Left" TextWrapping="Wrap" TextTrimming="None" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Type TreeView}" TargetType="{x:Type TreeView}">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TreeView">
                    <Border Name="Border" BorderThickness="0" BorderBrush="{x:Null}" Background="{StaticResource WhiteBrushKey}">
                        <ScrollViewer Focusable="False" CanContentScroll="False" Padding="2">
                            <ItemsPresenter />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ExpandCollapseToggleTreeviewStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid Width="12" Height="13" Background="Transparent" x:Name="Root">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CheckStates">
                                <VisualState x:Name="Checked">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="Collapsed">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="Expanded">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unchecked" />
                                <VisualState x:Name="Indeterminate" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="Collapsed" Storyboard.TargetProperty="(Path.Stroke).Color" To="#FF1BBBFA" Duration="0" />
                                        <ColorAnimation Storyboard.TargetName="Collapsed" Storyboard.TargetProperty="(Path.Fill).Color" To="#FF1BBBFA" Duration="00:00:0.3"  />
                                        <ColorAnimation Storyboard.TargetName="Expanded" Storyboard.TargetProperty="(Path.Fill).Color" To="#FF1BBBFA" Duration="00:00:0.3"  />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To=".7" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Path x:Name="Collapsed" Width="6" Height="9" Fill="#FFFFFFFF" Stroke="#FF989898" VerticalAlignment="Center" HorizontalAlignment="Left" Data="M 0,0 L 0,9 L 5,4.5 Z" StrokeThickness="1" StrokeLineJoin="Miter" />
                        <Path x:Name="Expanded" Width="6" Height="6" Fill="#FF262626" Stroke="#FFFFFFFF" VerticalAlignment="Center" HorizontalAlignment="Left" Data="M 6,0 L 6,6 L 0,6 Z" StrokeThickness="0" StrokeLineJoin="Miter" Visibility="Hidden" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Type TreeViewItem}" TargetType="{x:Type TreeViewItem}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment,  RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeViewItem}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MinWidth="12" Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource LightBlueColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unselected" />
                                <VisualState x:Name="SelectedInactive">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource SelectedUnfocusedColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ExpansionStates">
                                <VisualState x:Name="Expanded">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ItemsHost">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Collapsed" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ToggleButton x:Name="Expander" Visibility="Hidden" Style="{StaticResource ExpandCollapseToggleTreeviewStyle}" ClickMode="Press" IsChecked="{Binding IsExpanded,  RelativeSource={RelativeSource TemplatedParent}}"/>
                        <Border x:Name="Bd"
                                Grid.Column="1"
                                CornerRadius="1"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Padding="{TemplateBinding Padding}">
                            <ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                                <ContentPresenter.Content>
                                    <TextBlock Grid.Column="1" Margin="3,0" Text="{Binding Header, RelativeSource={RelativeSource AncestorType=TreeViewItem}}" />
                                </ContentPresenter.Content>
                            </ContentPresenter>
                        </Border>
                        <ItemsPresenter x:Name="ItemsHost"
                                          Grid.Row="1"
                                          Grid.Column="1"
                                          Grid.ColumnSpan="2"
                                          Visibility="Collapsed" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasItems" Value="true">
                            <Setter TargetName="Expander" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="HasHeader" Value="false" />
                                <Condition Property="Width" Value="Auto" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_Header" Property="MinWidth" Value="75" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="HasHeader" Value="false" />
                                <Condition Property="Height" Value="Auto" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_Header" Property="MinHeight" Value="19" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RobotFeaturesPopupStyle" TargetType="{x:Type Popup}">
        <Setter Property="AllowsTransparency" Value="True"/>
        <Setter Property="MaxHeight" Value="500" />
        <Setter Property="MaxWidth" Value="300"/>
        <Setter Property="PopupAnimation" Value="Fade" />
        <Setter Property="StaysOpen" Value="False"/>
        <Setter Property="Placement" Value="Bottom" />
    </Style>

    <Style x:Key="ModuleFeaturesPopupStyle" TargetType="{x:Type Popup}">
        <Setter Property="AllowsTransparency" Value="True"/>
        <Setter Property="MaxHeight" Value="500" />
        <Setter Property="PopupAnimation" Value="Fade" />
        <Setter Property="StaysOpen" Value="False"/>
        <Setter Property="Placement" Value="MousePoint" />
    </Style>

    <Style x:Key="featuresTooltipStyle" TargetType="{x:Type ToolTip}">
        <!-- DO NOT CHANGE THE NAME -->
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Padding" Value="0"/>
        <Setter Property="UseLayoutRounding" Value="True"/>
        <Setter Property="HasDropShadow" Value="False"/>
        <Setter Property="ToolTipService.ShowDuration" Value="30000"/>
        <Setter Property="ToolTipService.InitialShowDelay" Value="5000" />
        <Setter Property="ToolTipService.ShowOnDisabled" Value="false" />
        <Setter Property="ToolTipService.BetweenShowDelay" Value="5000" />
    </Style>

    <Style x:Key="FlatButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border x:Name="Border" BorderThickness="1" BorderBrush="{StaticResource TransparentBrushKey}" Background="{StaticResource TransparentBrushKey}" CornerRadius="2">
                        <ContentPresenter
                            Margin="1"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"/>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Unfocused"/>
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource GrayBlueColor}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                                                Storyboard.TargetName="Border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource AlphaGrayBlueColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.3" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource UltraLightGrayColor}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                                                Storyboard.TargetName="Border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource GrayBlueColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource GrayBlueColor}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                                                Storyboard.TargetName="Border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource AlphaGrayBlueColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames
                                            Storyboard.TargetName="Border"
                                            Storyboard.TargetProperty="Opacity">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.5"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsDefault" Value="True"/>
                                <Condition Property="IsEnabled" Value="True"/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource GrayBlueBrushKey}" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="FlatToggleButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border x:Name="Border" 
                            BorderThickness="1" 
                            BorderBrush="{x:Null}" 
                            Background="{TemplateBinding Background}">
                        <ContentPresenter
                            Margin="1"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"/>
                        <!--<VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Unfocused"/>
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource GrayBlueColor}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                                                Storyboard.TargetName="Border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource AlphaGrayBlueColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.3" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource UltraLightGrayColor}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                                                Storyboard.TargetName="Border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource GrayBlueColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource GrayBlueColor}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                                                Storyboard.TargetName="Border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource AlphaGrayBlueColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames
                                            Storyboard.TargetName="Border"
                                            Storyboard.TargetProperty="Opacity">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.5"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>-->
                    </Border>
                    <ControlTemplate.Triggers>
                        <!--<Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource GrayBlueBrushKey}" />
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource GrayBlueBrushKey}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsEnabled" Value="True"/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource GrayBlueBrushKey}" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>-->
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DialogButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource FlatButtonStyle}">
        <Setter Property="MinWidth" Value="75"/>
        <Setter Property="MinHeight" Value="23"/>
        <Setter Property="Margin" Value="2,7,7,11"/>
    </Style>

    <Style x:Key="FlatRepeatButtonStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border x:Name="Border" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{StaticResource TransparentBrushKey}" Background="{StaticResource TransparentBrushKey}" CornerRadius="2">
                        <ContentPresenter
                            Margin="1"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"/>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Unfocused"/>
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource GrayBlueColor}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                                                Storyboard.TargetName="Border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource UltraLightGrayColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.3" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource UltraLightGrayColor}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                                                Storyboard.TargetName="Border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource GrayBlueColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource GrayBlueColor}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                                                Storyboard.TargetName="Border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource UltraLightGrayColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames
                                            Storyboard.TargetName="Border"
                                            Storyboard.TargetProperty="Opacity">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.5"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ModuleActivationButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border x:Name="Border" BorderThickness="1" BorderBrush="{StaticResource TransparentBrushKey}" Background="{StaticResource TransparentBrushKey}" CornerRadius="2">
                        <ContentPresenter
                            Margin="1"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"/>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Unfocused"/>
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource GrayBlueColor}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                                                Storyboard.TargetName="Border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource AlphaGrayBlueColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.3" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource UltraLightGrayColor}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                                                Storyboard.TargetName="Border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource GrayBlueColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource GrayBlueColor}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                                                Storyboard.TargetName="Border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource AlphaGrayBlueColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames
                                            Storyboard.TargetName="Border"
                                            Storyboard.TargetProperty="Opacity">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.5"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource GrayBlueBrushKey}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsEnabled" Value="True"/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource GrayBlueBrushKey}" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="ExtensionSliderTemplate" TargetType="{x:Type local:SliderEx}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}" />
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal" Grid.Row="0">
                <RepeatButton x:Name="decreaseButton" Width="12" Height="12" Margin="1,0" Style="{StaticResource FlatRepeatButtonStyle}" Command="Slider.DecreaseLarge" Effect="{StaticResource DropShadowEffectLight}" ToolTip="{x:Static Resources:Messages.label_decrease_level}" Focusable="False" >
                    <Image Style="{StaticResource decreaseImageStyle}"/>
                </RepeatButton>
                <RepeatButton x:Name="increaseButton" Width="12" Height="12" Margin="1,0" Style="{StaticResource FlatRepeatButtonStyle}" Command="Slider.IncreaseLarge" Effect="{StaticResource DropShadowEffectLight}" ToolTip="{x:Static Resources:Messages.label_increase_level}" Focusable="False" >
                    <Image Style="{StaticResource increaseImageStyle}" />
                </RepeatButton>
            </StackPanel>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="CanIncrease" Value="False">
                <Setter Property="IsEnabled" Value="True" TargetName="decreaseButton"/>
                <Setter Property="IsEnabled" Value="False" TargetName="increaseButton"/>
            </Trigger>
            <Trigger Property="CanDecrease" Value="False">
                <Setter Property="IsEnabled" Value="True" TargetName="increaseButton"/>
                <Setter Property="IsEnabled" Value="False" TargetName="decreaseButton"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="ExtensionLevelSliderStyle" TargetType="{x:Type local:SliderEx}">
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="Margin" Value="5,1" />
        <Setter Property="Template" Value="{StaticResource ExtensionSliderTemplate}" />
    </Style>
    
    <Style x:Key="RobotMenuItemStyle" TargetType="{x:Type MenuItem}">
        <!-- DO NOT CHANGE THE NAME -->
        <Setter Property="IsEnabled" Value="{Binding DataContext.HasSelectedAgent, RelativeSource={RelativeSource AncestorType=Window}}"/>
        <Setter Property="Command" Value="{Binding DataContext.NewFittingCommand, RelativeSource={RelativeSource AncestorType=Window}}" />
        <Setter Property="CommandParameter" Value="{Binding Tag, RelativeSource={RelativeSource Mode=Self}}"/>
    </Style>
    
    <Style x:Key="FlatToggleButtonRobotInfoStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border x:Name="Border" BorderThickness="0" BorderBrush="{StaticResource TransparentBrushKey}" Background="{StaticResource TransparentBrushKey}" CornerRadius="6">
                        <ContentPresenter
                            Margin="1"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"/>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Unfocused"/>
                                <VisualState x:Name="Focused" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Pressed"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                                                Storyboard.TargetName="Border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource AlphaGrayBlueColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                        <ThicknessAnimationUsingKeyFrames
                                            Storyboard.TargetProperty="BorderThickness"
                                            Storyboard.TargetName="Border">
                                            <EasingThicknessKeyFrame KeyTime="0" Value="-1" />
                                        </ThicknessAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames
                                            Storyboard.TargetName="Border"
                                            Storyboard.TargetProperty="Opacity">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0.5"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Border>
                    <ControlTemplate.Triggers>
                        <!--<Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource GrayBlueBrushKey}" />
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource GrayBlueBrushKey}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsEnabled" Value="True"/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource GrayBlueBrushKey}" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>-->
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="TechnologyLevelImageStyle" TargetType="{x:Type Image}">
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="Effect" Value="{StaticResource DropShadowEffect}"/>
    </Style>

    <DataTemplate x:Key="AmmunitionFeatureHeaderTemplate" DataType="{x:Type Base:AmmunitionBase}">
        <Grid ToolTip="{Binding Name}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="1*" />
            </Grid.ColumnDefinitions>
            <Image x:Name="HeaderImage" 
                   Grid.Column="0"
                   MaxHeight="18"
                   Margin="5,2"
                   Style="{StaticResource TechnologyLevelImageStyle}"
                   Source="{Binding Mode=OneTime, Converter={StaticResource AmmunitionToImageSourceConverter}}" />
            <TextBlock 
                x:Name="HeaderText" 
                Grid.Column="1"
                VerticalAlignment="Center"
                HorizontalAlignment="Stretch"
                Margin="5,0,5,0"
                Text="{Binding Name}"
                TextTrimming="CharacterEllipsis" />
        </Grid>
    </DataTemplate>
    
    <DataTemplate x:Key="ModuleFeatureHeaderTemplate" DataType="{x:Type Base:ModuleBase}">
        <Grid ToolTip="{Binding Name}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Image x:Name="HeaderImage" 
                   Grid.Column="0"  
                   Margin="5,6"
                   Style="{StaticResource TechnologyLevelImageStyle}"
                   Source="{Binding TechnologyLevel, Converter={StaticResource ModuleTechnologyToImageConverter}, Mode=OneTime}" />

            <TextBlock 
                x:Name="HeaderText" 
                Grid.Column="1"
                VerticalAlignment="Center"
                HorizontalAlignment="Stretch"
                Margin="5,0,5,0"
                Text="{Binding Name}"
                TextTrimming="CharacterEllipsis" />

            <StackPanel Orientation="Horizontal" Grid.Column="2">
                <Image
                    Margin="1,0"
                    MinWidth="0" MinHeight="0"
                    MaxWidth="15" MaxHeight="15"
                    Effect="{StaticResource DropShadowEffect}"
                    Source="{Binding SlotGroup, Converter={StaticResource SlotGroupEnumToImageConverter}}" />
                <Image
                    Margin="1,0"
                    MinWidth="0" MinHeight="0"
                    MaxWidth="15" MaxHeight="15"
                    Effect="{StaticResource DropShadowEffect}"
                    Source="{Binding SlotType, Converter={StaticResource SlotTypeToImageSourceConverter}}" />
                <Image
                    Margin="1,0"
                    MinWidth="0" MinHeight="0"
                    MaxWidth="15" MaxHeight="15"
                    Effect="{StaticResource DropShadowEffect}"
                    Source="{Binding Size, Converter={StaticResource SizesEnumToImageSourceConverter}}" />
            </StackPanel>

        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="FeaturesGroupHeaderTemplate" >
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="1*" />
            </Grid.ColumnDefinitions>

            <Image x:Name="HeaderImage" 
                                Grid.Column="0"  
                                Style="{StaticResource HeaderImage}"
                                Source="{Binding Converter={StaticResource FeatureGroupEnumToImageSourceConverter}, IsAsync=True}" />

            <TextBlock x:Name="HeaderText" 
                                    Grid.Column="1"
                                    VerticalAlignment="Center"
                                    HorizontalAlignment="Stretch"
                                    Margin="5,0,0,0"
                                    Text="{Binding Converter={StaticResource FeatureGroupEnumToLabelConverter}, IsAsync=True}" />
        </Grid>
    </DataTemplate>
    
    <DataTemplate x:Key="FeatureItemTemplate" >
        <Grid x:Name="root" Margin="5,2" ToolTip="{Binding Name}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBlock x:Name="FeatureName" 
                        Grid.Column="0"
                        Text="{Binding Name}"
                        TextTrimming="CharacterEllipsis"
                        VerticalAlignment="Center" 
                        HorizontalAlignment="Left"/>
            <TextBlock 
                    x:Name="FeatureValue" 
                    Text="{Binding FormattedValue}" 
                    Grid.Column="1" 
                    VerticalAlignment="Center" 
                    HorizontalAlignment="Right"/>
        </Grid>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsModified}" Value="True">
                <Setter TargetName="FeatureName" Property="FontWeight" Value="Bold" />
                <Setter TargetName="FeatureValue" Property="FontWeight" Value="Bold" />
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="ModifierItemTemplate" DataType="{x:Type Core:Modifier}" >
        <Grid x:Name="ContentGrid" 
              Margin="5,2" 
              ToolTip="{Binding DisplayName, Mode=OneTime}" 
              Visibility="{Binding IsVisible, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneTime}">
            
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            
            <TextBlock 
                x:Name="DisplayName" 
                Grid.Column="0"
                Text="{Binding DisplayName, Mode=OneTime}" 
                VerticalAlignment="Center" 
                HorizontalAlignment="Left"/>

            <TextBlock 
                x:Name="Activation" 
                Grid.Column="1"
                Margin="2,0,5,0"
                Text="{Binding ActivationState, StringFormat=({0}), Mode=OneTime}" 
                VerticalAlignment="Center" 
                HorizontalAlignment="Right"/>

            <TextBlock 
                x:Name="Value" 
                Grid.Column="2" 
                Text="{Binding FormattedValue, Mode=OneTime}" 
                VerticalAlignment="Center" 
                HorizontalAlignment="Right"/>
        </Grid>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding ActivationState}" Value="{x:Static Enums:ModuleActivationTypesEnum.NotDefined}">
                <Setter TargetName="Activation" Property="Visibility" Value="Collapsed"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="BonusModifierItemTemplate" DataType="{x:Type Core:BonusModifier`1}">
        <Grid x:Name="ContentGrid" 
              Margin="5,2" 
              ToolTip="{Binding DisplayName, Mode=OneTime}" 
              Visibility="{Binding IsVisible, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneTime}">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <TextBlock 
                x:Name="DisplayName" 
                Grid.Column="0"
                Text="{Binding DisplayName, Mode=OneTime}" 
                VerticalAlignment="Center" 
                HorizontalAlignment="Left"/>

            <TextBlock 
                x:Name="Value" 
                Grid.Column="1" 
                Text="{Binding FormattedValue, Mode=OneTime}" 
                VerticalAlignment="Center" 
                HorizontalAlignment="Right"/>
        </Grid>
    </DataTemplate>
    
    
    <Style x:Key="RobotFeaturesItemsControlStyle" TargetType="{x:Type HeaderedItemsControl}">
        <Setter Property="Background" Value="{StaticResource WhiteBrushKey}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type HeaderedItemsControl}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border x:Name="HeaderBorder" 
                                Grid.Row="0"
                                Padding="2,1,2,1"
                                CornerRadius="2,2,0,0"
                                BorderThickness="1,1,1,0"
                                Background="{StaticResource DarkBrush}"
                                BorderBrush="{StaticResource GrayBlueBrushKey}">
                            <ContentPresenter ContentSource="Header" Grid.Row="0" />
                        </Border>
                        <Border x:Name="ContentBorder" 
                                Grid.Row="1"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{StaticResource GrayBlueBrushKey}" 
                                BorderThickness="1,0,1,1" 
                                CornerRadius="0,0,2,2">
                            <StackPanel 
                                x:Name="host"
                                IsItemsHost="True" 
                                Orientation="Vertical"
                                HorizontalAlignment="Stretch">
                            </StackPanel>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Header" Value="{x:Null}" >
                            <Setter Property="Height" TargetName="HeaderBorder" Value="0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="HeaderTemplate" Value="{StaticResource FeaturesGroupHeaderTemplate}" />
        <Setter Property="ItemTemplate" Value="{StaticResource FeatureItemTemplate}" />
    </Style>

    <Style x:Key="RobotModifiersItemsControlStyle" TargetType="{x:Type HeaderedItemsControl}">
        <Setter Property="Background" Value="{StaticResource WhiteBrushKey}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type HeaderedItemsControl}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="HeaderRow" Height="Auto" />
                            <RowDefinition x:Name="ContentRow" Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border x:Name="HeaderBorder" 
                                Grid.Row="0"
                                Padding="2,1,2,1"
                                CornerRadius="2,2,0,0"
                                BorderThickness="1,1,1,0"
                                Background="{StaticResource DarkBrush}"
                                BorderBrush="{StaticResource GrayBlueBrushKey}">
                            <ContentPresenter ContentSource="Header" Grid.Row="0" />
                        </Border>
                        <Border x:Name="ContentBorder" 
                                Grid.Row="1" 
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                CornerRadius="2">
                            <StackPanel 
                                IsItemsHost="True" 
                                Orientation="Vertical"
                                HorizontalAlignment="Stretch">
                            </StackPanel>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Header" Value="{x:Null}" >
                            <Setter Property="Height" TargetName="HeaderRow" Value="0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemTemplate" Value="{StaticResource BonusModifierItemTemplate}" />
    </Style>
    
    
    <Style x:Key="ModuleFeaturesItemsControlStyle" TargetType="{x:Type HeaderedItemsControl}">
        <Setter Property="Width" Value="300" />
        <Setter Property="Background" Value="{StaticResource WhiteBrushKey}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type HeaderedItemsControl}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border x:Name="HeaderBorder" 
                                Grid.Row="0"
                                Padding="2,1,2,1"
                                CornerRadius="2,2,0,0"
                                BorderThickness="1,1,1,0"
                                Background="{StaticResource DarkBrush}"
                                BorderBrush="{StaticResource GrayBlueBrushKey}">
                            <ContentPresenter ContentSource="Header" Grid.Row="0"  />
                        </Border>
                        <Border x:Name="ContentBorder" 
                                Grid.Row="1" 
                                Background="{TemplateBinding Background}"
                                BorderBrush="{StaticResource GrayBlueBrushKey}" 
                                BorderThickness="1,0,1,1" 
                                CornerRadius="0,0,2,2">
                            <StackPanel 
                                x:Name="host"
                                IsItemsHost="True" 
                                Orientation="Vertical"
                                HorizontalAlignment="Stretch">
                            </StackPanel>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Header" Value="{x:Null}" >
                            <Setter Property="Height" TargetName="HeaderBorder" Value="0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="HeaderTemplate" Value="{StaticResource ModuleFeatureHeaderTemplate}" />
        <Setter Property="ItemTemplate" Value="{StaticResource FeatureItemTemplate}" />
    </Style>

    <Style x:Key="ModuleModifiersItemsControlStyle" TargetType="{x:Type HeaderedItemsControl}">
        <Setter Property="Width" Value="300" />
        <Setter Property="Background" Value="{StaticResource WhiteBrushKey}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type HeaderedItemsControl}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="HeaderRow" Height="Auto" />
                            <RowDefinition x:Name="ContentRow" Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border x:Name="HeaderBorder" 
                                Grid.Row="0"
                                Padding="2,1,2,1"
                                CornerRadius="2,2,0,0"
                                BorderThickness="1,1,1,0"
                                Background="{StaticResource DarkBrush}"
                                BorderBrush="{StaticResource GrayBlueBrushKey}">
                            <ContentPresenter ContentSource="Header" Grid.Row="0" />
                        </Border>
                        <Border x:Name="ContentBorder" 
                                Grid.Row="1" 
                                Background="{TemplateBinding Background}"
                                BorderBrush="{StaticResource GrayBlueBrushKey}" 
                                BorderThickness="1" 
                                CornerRadius="2">
                            <StackPanel 
                                IsItemsHost="True" 
                                Orientation="Vertical"
                                HorizontalAlignment="Stretch">
                            </StackPanel>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Header" Value="{x:Null}" >
                            <Setter Property="Height" TargetName="HeaderRow" Value="0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <!--<Setter Property="HeaderTemplate" Value="{StaticResource ModuleFeatureHeaderTemplate}" />-->
        <Setter Property="ItemTemplate" Value="{StaticResource ModifierItemTemplate}" />
    </Style>

    <Style x:Key="AmmunitionFeaturesItemsControlStyle" TargetType="{x:Type HeaderedItemsControl}">
        <Setter Property="Width" Value="300" />
        <Setter Property="Background" Value="{StaticResource WhiteBrushKey}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type HeaderedItemsControl}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border x:Name="HeaderBorder" 
                                Grid.Row="0"
                                Padding="2,1,2,1"
                                CornerRadius="2,2,0,0"
                                BorderThickness="1,1,1,0"
                                Background="{StaticResource DarkBrush}"
                                BorderBrush="{StaticResource GrayBlueBrushKey}">
                            <ContentPresenter ContentSource="Header" Grid.Row="0"  />
                        </Border>
                        <Border x:Name="ContentBorder" 
                                Grid.Row="1" 
                                Background="{TemplateBinding Background}"
                                BorderBrush="{StaticResource GrayBlueBrushKey}" 
                                BorderThickness="1,0,1,1" 
                                CornerRadius="0,0,2,2">
                            <StackPanel 
                                x:Name="host"
                                IsItemsHost="True" 
                                Orientation="Vertical"
                                HorizontalAlignment="Stretch">
                            </StackPanel>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Header" Value="{x:Null}" >
                            <Setter Property="Height" TargetName="HeaderBorder" Value="0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="HeaderTemplate" Value="{StaticResource AmmunitionFeatureHeaderTemplate}" />
        <Setter Property="ItemTemplate" Value="{StaticResource FeatureItemTemplate}" />
    </Style>
    
    <Style x:Key="AmmunitionModifiersItemsControlStyle" TargetType="{x:Type HeaderedItemsControl}">
        <Setter Property="Width" Value="300" />
        <Setter Property="Background" Value="{StaticResource WhiteBrushKey}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type HeaderedItemsControl}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="HeaderRow" Height="Auto" />
                            <RowDefinition x:Name="ContentRow" Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border x:Name="HeaderBorder" 
                                Grid.Row="0"
                                Padding="2,1,2,1"
                                CornerRadius="2,2,0,0"
                                BorderThickness="1,1,1,0"
                                Background="{StaticResource DarkBrush}"
                                BorderBrush="{StaticResource GrayBlueBrushKey}">
                            <ContentPresenter ContentSource="Header" Grid.Row="0" />
                        </Border>
                        <Border x:Name="ContentBorder" 
                                Grid.Row="1" 
                                Background="{TemplateBinding Background}"
                                BorderBrush="{StaticResource GrayBlueBrushKey}" 
                                BorderThickness="1" 
                                CornerRadius="2">
                            <StackPanel 
                                IsItemsHost="True" 
                                Orientation="Vertical"
                                HorizontalAlignment="Stretch">
                            </StackPanel>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Header" Value="{x:Null}" >
                            <Setter Property="Height" TargetName="HeaderRow" Value="0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <!--<Setter Property="HeaderTemplate" Value="{StaticResource ModuleFeatureHeaderTemplate}" />-->
        <Setter Property="ItemTemplate" Value="{StaticResource ModifierItemTemplate}" />
    </Style>
    
    <DataTemplate x:Key="ExtensionItemTemplate" DataType="{x:Type Base:ExtensionBase}">
        <Grid Name="itemContent">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="20"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="45"/>
                <ColumnDefinition Width="30"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Text="{Binding Name,Mode=OneTime}" HorizontalAlignment="Left" Margin="5,0,10,0" >
                <TextBlock.ToolTip>
                    <ToolTip Content="{Binding Description,Mode=OneTime}" HasDropShadow="False"/>
                </TextBlock.ToolTip>
            </TextBlock>
            <TextBlock Grid.Column="1" Text="{Binding Complexity,StringFormat=[{0}],Mode=OneTime}" HorizontalAlignment="Left" ToolTip="{x:Static Resources:Messages.label_complexity}" />
            <Canvas Grid.Column="4" Margin="5,0" Height="16px" HorizontalAlignment="Left">
                <Rectangle Name="rectBackground" Canvas.Left="0" Canvas.Top="2" Width="41" Height="12" Fill="#FF008000" />
                <Rectangle Name="rectLevel1" Canvas.Left="1" Canvas.Top="3" Width="3" Height="10" RadiusY="0.25" Fill="{x:Null}"/>
                <Rectangle Name="rectLevel2" Canvas.Left="5" Canvas.Top="3" Width="3" Height="10" RadiusY="0.25" Fill="{x:Null}"/>
                <Rectangle Name="rectLevel3" Canvas.Left="9" Canvas.Top="3" Width="3" Height="10" RadiusY="0.25"  Fill="{x:Null}"/>
                <Rectangle Name="rectLevel4" Canvas.Left="13" Canvas.Top="3" Width="3" Height="10" RadiusY="0.25"  Fill="{x:Null}"/>
                <Rectangle Name="rectLevel5" Canvas.Left="17" Canvas.Top="3" Width="3" Height="10" RadiusY="0.25" Fill="{x:Null}"/>
                <Rectangle Name="rectLevel6" Canvas.Left="21" Canvas.Top="3" Width="3" Height="10" RadiusY="0.25" Fill="{x:Null}"/>
                <Rectangle Name="rectLevel7" Canvas.Left="25" Canvas.Top="3" Width="3" Height="10" RadiusY="0.25" Fill="{x:Null}"/>
                <Rectangle Name="rectLevel8" Canvas.Left="29" Canvas.Top="3" Width="3" Height="10" RadiusY="0.25" Fill="{x:Null}"/>
                <Rectangle Name="rectLevel9" Canvas.Left="33" Canvas.Top="3" Width="3" Height="10" RadiusY="0.25" Fill="{x:Null}"/>
                <Rectangle Name="rectLevel10" Canvas.Left="37" Canvas.Top="3" Width="3" Height="10" RadiusY="0.25" Fill="{x:Null}"/>
            </Canvas>
            <TextBlock x:Name="txtCurrentLevel" Grid.Column="5" Margin="5,2" Text="{Binding Level, StringFormat=({0})}" ToolTip="{x:Static Resources:Messages.label_current_level}" VerticalAlignment="Center" HorizontalAlignment="Center" />
            <local:SliderEx Grid.Column="6" Value="{Binding Level, Mode=TwoWay}" Minimum="0" Maximum="10" Style="{StaticResource ExtensionLevelSliderStyle}" />
        </Grid>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Level}" Value="0">
                <Setter TargetName="rectBackground" Property="Fill" Value="{x:Null}"/>
                <Setter TargetName="txtCurrentLevel" Property="Visibility" Value="Hidden" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Level}" Value="1">
                <Setter TargetName="rectLevel1" Property="Fill" Value="#FF00FF00"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Level}" Value="2">
                <Setter TargetName="rectLevel1" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel2" Property="Fill" Value="#FF00FF00"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Level}" Value="3">
                <Setter TargetName="rectLevel1" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel2" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel3" Property="Fill" Value="#FF00FF00"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Level}" Value="4">
                <Setter TargetName="rectLevel1" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel2" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel3" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel4" Property="Fill" Value="#FF00FF00"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Level}" Value="5">
                <Setter TargetName="rectLevel1" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel2" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel3" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel4" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel5" Property="Fill" Value="#FF00FF00"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Level}" Value="6">
                <Setter TargetName="rectLevel1" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel2" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel3" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel4" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel5" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel6" Property="Fill" Value="#FF00FF00"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Level}" Value="7">
                <Setter TargetName="rectLevel1" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel2" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel3" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel4" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel5" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel6" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel7" Property="Fill" Value="#FF00FF00"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Level}" Value="8">
                <Setter TargetName="rectLevel1" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel2" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel3" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel4" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel5" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel6" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel7" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel8" Property="Fill" Value="#FF00FF00"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Level}" Value="9">
                <Setter TargetName="rectLevel1" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel2" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel3" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel4" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel5" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel6" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel7" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel8" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel9" Property="Fill" Value="#FF00FF00"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Level}" Value="10">
                <Setter TargetName="rectLevel1" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel2" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel3" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel4" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel5" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel6" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel7" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel8" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel9" Property="Fill" Value="#FF00FF00"/>
                <Setter TargetName="rectLevel10" Property="Fill" Value="#FF00FF00"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
    
    <Style x:Key="ExtensionItemsControlStyle" TargetType="{x:Type HeaderedItemsControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type HeaderedItemsControl}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition x:Name="ContentRow" Height="0" />
                        </Grid.RowDefinitions>
                        <Border x:Name="HeaderBorder" 
                                Grid.Row="0"
                                Padding="2,1,2,1"
                                CornerRadius="2"
                                BorderThickness="1,1,1,1"
                                Background="{StaticResource WhiteBrushKey}"
                                BorderBrush="{StaticResource GrayBlueBrushKey}">
                            <ToggleButton x:Name="toggleButton" 
                                          Background="{TemplateBinding Background}"
                                          HorizontalContentAlignment="Left"  
                                          HorizontalAlignment="Stretch" 
                                          Style="{StaticResource FlatToggleButtonStyle}" >
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="1*" />
                                    </Grid.ColumnDefinitions>
                                    <Path Name="Arrow" 
                                          Grid.Column="0"
                                          Fill="{StaticResource GlyphBrush}" 
                                          Margin="2,0,0,0"
                                          HorizontalAlignment="Left" 
                                          VerticalAlignment="Center" 
                                          Data="M 0 0 L 4 4 L 8 0 Z"/>
                                    <TextBlock x:Name="ToggleButtonText"
                                        Grid.Column="1"
                                        Margin="5,0,2,0" 
                                        TextTrimming="CharacterEllipsis" 
                                        Text="{TemplateBinding Header}"
                                        FontWeight="Normal"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Center" />
                                </Grid>
                                
                            </ToggleButton>
                        </Border>
                        <Border x:Name="ContentBorder" 
                                Grid.Row="1" 
                                Background="{TemplateBinding Background}"
                                BorderBrush="{StaticResource GrayBlueBrushKey}" 
                                BorderThickness="0" 
                                CornerRadius="0">
                            <StackPanel 
                                IsItemsHost="True" 
                                Orientation="Vertical"
                                HorizontalAlignment="Stretch">
                            </StackPanel>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" SourceName="toggleButton"  Value="True">
                            <Setter TargetName="Arrow" Property="Data" Value="M 0 4 L 4 0 L 8 4 Z" />
                            <Setter TargetName="ContentRow" Property="Height" Value="{Binding ElementName=ContentBorder, Path=Height}" />
                            <Setter TargetName="ContentBorder" Property="BorderThickness" Value="1,0,1,1"/>
                            <Setter TargetName="ContentBorder" Property="CornerRadius" Value="0,0,2,2"/>
                            <Setter TargetName="HeaderBorder" Property="BorderThickness" Value="1,1,1,1"/>
                            <Setter TargetName="HeaderBorder" Property="CornerRadius" Value="2,2,0,0"/>
                            <Setter TargetName="ToggleButtonText" Property="Foreground" Value="#FFFFFFFF" />
                            <Setter TargetName="toggleButton" Property="Background" Value="#17A5D1" />
                            <Setter TargetName="HeaderBorder" Property="Background" Value="#17A5D1" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" SourceName="toggleButton" Value="true">
                            <Setter TargetName="Arrow" Property="Fill" Value="#FFFFFFFF" />
                            <Setter TargetName="ToggleButtonText" Property="Foreground" Value="#FFFFFFFF" />
                            <Setter TargetName="toggleButton" Property="Background" Value="#009CCC" />
                            <Setter TargetName="HeaderBorder" Property="Background" Value="#009CCC" />
                            <Setter TargetName="HeaderBorder" Property="Effect" Value="{StaticResource DropShadowEffectLight}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemTemplate" Value="{StaticResource ExtensionItemTemplate}" />
    </Style>
    
    <ControlTemplate x:Key="ModuleTreeviewItemTemplate" TargetType="{x:Type TreeViewItem}">
        <!-- DO NOT CHANGE NAME -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="12" Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="SelectionStates">
                    <VisualState x:Name="Selected">
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource LightBlueColor}" />
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Unselected" />
                    <VisualState x:Name="SelectedInactive">
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource SelectedUnfocusedColor}" />
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="ExpansionStates">
                    <VisualState x:Name="Expanded">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ItemsHost">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Collapsed" />
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <ToggleButton x:Name="Expander" Style="{StaticResource ExpandCollapseToggleTreeviewStyle}" ClickMode="Press" IsChecked="{Binding IsExpanded,  RelativeSource={RelativeSource TemplatedParent}}"/>
            <Border x:Name="Bd"
                    Grid.Column="1"
                    CornerRadius="1"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    Padding="{TemplateBinding Padding}">
                <ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                    <ContentPresenter.Content>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="1*"/>
                            </Grid.ColumnDefinitions>
                            <ToggleButton x:Name="tgButton" Grid.Column="0" Visibility="Collapsed" Width="14" Height="14" Style="{StaticResource FlatToggleButtonRobotInfoStyle}" ToolTip="{x:Static Resources:Messages.label_show_module_details}">
                                <ToggleButton.Content>
                                    <Image Source="/Profit;component/Resources/Icons/info_12.png" />
                                </ToggleButton.Content>
                            </ToggleButton>
                            <Image Grid.Column="1" Margin="2,0" VerticalAlignment="Center" Effect="{StaticResource DropShadowEffectLight}" Source="{Binding TechnologyLevel, Converter={StaticResource ModuleTechnologyToImageConverter}}"/>
                            <TextBlock Grid.Column="2" Margin="3,0" VerticalAlignment="Center" Text="{Binding Header, RelativeSource={RelativeSource AncestorType=TreeViewItem}, Mode=OneTime}" />
                            
                            <Popup x:Name="featuresPopup" Style="{StaticResource ModuleFeaturesPopupStyle}" DataContext="{TemplateBinding DataContext}" IsOpen="{Binding IsChecked, ElementName=tgButton}">
                                <Border Padding="2" Background="{StaticResource TransparentBrushKey}" BorderBrush="{x:Null}" BorderThickness="0" CornerRadius="3">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="1*"/>
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition MaxWidth="300" />
                                        </Grid.ColumnDefinitions>
                                        <ScrollViewer Grid.Row="1" Grid.ColumnSpan="2" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" >
                                            <StackPanel Orientation="Vertical">

                                                <HeaderedItemsControl
                                                    x:Name="ModuleFeaturesPanel"
                                                    Style="{StaticResource ModuleFeaturesItemsControlStyle}"
                                                    Header="{Binding}" 
                                                    ItemsSource="{Binding Features, Mode=OneTime}" />

                                                <HeaderedItemsControl
                                                    x:Name="ModuleModifiersPanel"
                                                    Visibility="{Binding HasVisibleModifiers, Converter={StaticResource BooleanToVisibilityConverter}}"
                                                    Margin="0,3,0,0"
                                                    Style="{StaticResource ModuleModifiersItemsControlStyle}"
                                                    ItemsSource="{Binding Modifiers, Mode=OneTime}" />
                                            </StackPanel>
                                        </ScrollViewer>
                                    </Grid>
                                </Border>
                            </Popup>
                        </Grid>
                    </ContentPresenter.Content>
                </ContentPresenter>
            </Border>
            <ItemsPresenter x:Name="ItemsHost"
                          Grid.Row="1"
                          Grid.Column="1"
                          Grid.ColumnSpan="2"
                          Visibility="Collapsed" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Visibility" TargetName="tgButton" Value="Visible" />
            </Trigger>
            <Trigger Property="HasItems" Value="false">
                <Setter TargetName="Expander" Property="Visibility" Value="Hidden" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="HasHeader" Value="false" />
                    <Condition Property="Width" Value="Auto" />
                </MultiTrigger.Conditions>
                <Setter TargetName="PART_Header" Property="MinWidth" Value="75" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="HasHeader" Value="false" />
                    <Condition Property="Height" Value="Auto" />
                </MultiTrigger.Conditions>
                <Setter TargetName="PART_Header" Property="MinHeight" Value="19" />
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="RobotTreeviewItemTemplate" TargetType="{x:Type TreeViewItem}">
        <!-- DO NOT CHANGE NAME -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="12" Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="SelectionStates">
                    <VisualState x:Name="Selected">
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource LightBlueColor}" />
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Unselected" />
                    <VisualState x:Name="SelectedInactive">
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource SelectedUnfocusedColor}" />
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="ExpansionStates">
                    <VisualState x:Name="Expanded">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ItemsHost">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Collapsed" />
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <ToggleButton x:Name="Expander" Style="{StaticResource ExpandCollapseToggleTreeviewStyle}" ClickMode="Press" IsChecked="{Binding IsExpanded,  RelativeSource={RelativeSource TemplatedParent}}"/>
            <Border x:Name="Bd"
                                Grid.Column="1"
                                CornerRadius="1"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Padding="{TemplateBinding Padding}">
                <ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                    <ContentPresenter.Content>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="1*"/>
                            </Grid.ColumnDefinitions>
                            <ToggleButton  x:Name="tgButton" Visibility="Collapsed" Grid.Column="0" Style="{StaticResource FlatToggleButtonRobotInfoStyle}" Width="14" Height="14">
                                <ToggleButton.Content>
                                    <Image Source="/Profit;component/Resources/Icons/info_12.png" />
                                </ToggleButton.Content>
                                <ToggleButton.ToolTip>
                                    <ToolTip Content="{x:Static Resources:Messages.label_show_robot_details}"/>
                                </ToggleButton.ToolTip>
                            </ToggleButton>
                            <TextBlock Grid.Column="1" Margin="3,0" VerticalAlignment="Center" Text="{Binding Header, RelativeSource={RelativeSource AncestorType=TreeViewItem}}" />
                            <Popup x:Name="featuresPopup" Style="{StaticResource RobotFeaturesPopupStyle}" DataContext="{TemplateBinding DataContext}" IsOpen="{Binding IsChecked, ElementName=tgButton}">
                                <Border Padding="2" Background="{StaticResource WhiteBrushKey}" BorderBrush="{StaticResource GrayBlueBrushKey}" BorderThickness="1" CornerRadius="3">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition MaxHeight="128"/>
                                            <RowDefinition Height="1*"/>
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition MaxWidth="300" />
                                        </Grid.ColumnDefinitions>
                                        <Image Grid.Row="0" Grid.Column="0" MaxHeight="64" VerticalAlignment="Top" HorizontalAlignment="Left" Source="{Binding Mode=OneTime, Converter={StaticResource RobotToBitmapSourceConverter}}" />
                                        <ScrollViewer Grid.Row="0" Grid.Column="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
                                            <TextBlock Margin="5,2" Text="{Binding Description, Mode=OneTime}" TextAlignment="Left" TextWrapping="Wrap" />
                                        </ScrollViewer>

                                        <TabControl Grid.Row="1" Grid.ColumnSpan="2" BorderThickness="1" BorderBrush="{StaticResource GrayBlueBrushKey}" Background="{StaticResource TransparentBrushKey}">
                                            
                                            <!--Robot features-->
                                            <TabItem Header="Features" BorderBrush="{StaticResource GrayBlueBrushKey}" Background="{StaticResource WhiteBrushKey}">
                                                <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" >
                                                    <Grid>
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="Auto"/>
                                                            <RowDefinition Height="Auto"/>
                                                            <RowDefinition Height="Auto"/>
                                                            <RowDefinition Height="Auto"/>
                                                            <RowDefinition Height="Auto"/>
                                                        </Grid.RowDefinitions>

                                                        <HeaderedItemsControl 
                                                            Grid.Row="0" 
                                                            Margin="0,0,0,0"
                                                            Header="{x:Static Enums:FeatureGroupsEnum.Engine}"
                                                            Style="{StaticResource RobotFeaturesItemsControlStyle}"
                                                            ItemsSource="{Binding EngineFeatures, Mode=OneTime}" >
                                                        </HeaderedItemsControl>

                                                        <HeaderedItemsControl 
                                                            Grid.Row="1" 
                                                            Margin="0,2,0,0"
                                                            Header="{x:Static Enums:FeatureGroupsEnum.Defence}"
                                                            Style="{StaticResource RobotFeaturesItemsControlStyle}"
                                                            ItemsSource="{Binding DefenceFeatures, Mode=OneTime}" >
                                                        </HeaderedItemsControl>

                                                        <HeaderedItemsControl 
                                                            Grid.Row="2" 
                                                            Margin="0,2,0,0"
                                                            Header="{x:Static Enums:FeatureGroupsEnum.TargetingEquipment}"
                                                            Style="{StaticResource RobotFeaturesItemsControlStyle}"
                                                            ItemsSource="{Binding TargetingEquipmentFeatures, Mode=OneTime}" >
                                                        </HeaderedItemsControl>

                                                        <HeaderedItemsControl 
                                                            Grid.Row="3" 
                                                            Margin="0,2,0,0"
                                                            Header="{x:Static Enums:FeatureGroupsEnum.General}"
                                                            Style="{StaticResource RobotFeaturesItemsControlStyle}"
                                                            ItemsSource="{Binding GeneralFeatures, Mode=OneTime}" >
                                                        </HeaderedItemsControl>
                                                    </Grid>
                                                </ScrollViewer>
                                            </TabItem>
                                            
                                            <!--Robot Bonuses-->
                                            <TabItem Header="Bonus" BorderBrush="{StaticResource GrayBlueBrushKey}" Background="{StaticResource WhiteBrushKey}">
                                                <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" >
                                                    <Grid>
                                                        <HeaderedItemsControl 
                                                            Grid.Row="0" 
                                                            Margin="0,0,0,0"
                                                            Header="{x:Null}"
                                                            BorderBrush="{x:Null}"
                                                            Style="{StaticResource RobotModifiersItemsControlStyle}"
                                                            ItemsSource="{Binding Modifiers, Mode=OneTime}" >
                                                        </HeaderedItemsControl>

                                                    </Grid>
                                                </ScrollViewer>
                                            </TabItem>
                                        </TabControl>
                                        
                                        
                                    </Grid>
                                </Border>
                            </Popup>
                        </Grid>
                    </ContentPresenter.Content>
                </ContentPresenter>
            </Border>
            <ItemsPresenter x:Name="ItemsHost"
                          Grid.Row="1"
                          Grid.Column="1"
                          Grid.ColumnSpan="2"
                          Visibility="Collapsed" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Visibility" TargetName="tgButton" Value="Visible" />
            </Trigger>
            <Trigger Property="HasItems" Value="false">
                <Setter TargetName="Expander" Property="Visibility" Value="Hidden" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="HasHeader" Value="false" />
                    <Condition Property="Width" Value="Auto" />
                </MultiTrigger.Conditions>
                <Setter TargetName="PART_Header" Property="MinWidth" Value="75" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="HasHeader" Value="false" />
                    <Condition Property="Height" Value="Auto" />
                </MultiTrigger.Conditions>
                <Setter TargetName="PART_Header" Property="MinHeight" Value="19" />
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

</ResourceDictionary>